﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using hedefgrup.reports.renault.date;
using hedefgrup.reports.renault;

/// <summary>
/// Summary description for criteriaPage
/// </summary>
public class criteriaPage : reportPage
{
    protected void renderMonthSelection(Literal renderInto)
    {
        StringBuilder htmlBuilder = new StringBuilder();
        int i = 0;
        dataCache allData = dataCache.getDataCacheByProjectName(base.userProjectName, Global.MAKE_RENAULT_AND_DACIA);
        foreach (reportMonth month in allData.availableData)
        {
            htmlBuilder.AppendFormat("<option value='{0}' {1}>{2} {3}</option>", month.dateValue, i == 0 ? "selected" : "", month.getYear(), month.getMonthName());
            i++;
        }
        renderInto.Text = htmlBuilder.ToString();
    }

    public readonly string periodSelectionOptions =
        "<option value='1' selected>Ay</option>" +
        "<option value='2'>2 Ay</option>" +
        "<option value='3'>3 Ay</option>" +
        "<option value='4'>4 Ay</option>" +
        "<option value='5'>5 Ay</option>" +
        "<option value='6'>6 Ay</option>" +
        "<option value='7'>7 Ay</option>" +
        "<option value='8'>8 Ay</option>" +
        "<option value='9'>9 Ay</option>" +
        "<option value='10'>10 Ay</option>" +
        "<option value='11'>11 Ay</option>" +
        "<option value='12'>12 Ay</option>";

    public void renderMakeSelection(Literal renderInto)
    {
        StringBuilder makeSelectionBuilder = new StringBuilder();
        foreach (dataCache data in dataCache.orderedInstances)
        {
            if (data.projectName != base.userProjectName || data.hiddenState == "*" || (data.hiddenState == "dealer" && isDelaer()))
            {
                continue;
            }
            makeSelectionBuilder.AppendFormat("<option value=\"{0}\" {1}>{2}</option>", data.name, (data.isDefault || makeSelection == data.projectName ? "selected=\"selected\"" : ""), data.displayName);
        }
        renderInto.Text = makeSelectionBuilder.ToString();
    }

    protected void renderNetworkSelection()
    {
        renderNetworkSelection(false);
    }

    protected void renderNetworkSelection(bool excludeS3)
    {
        Literal networkListLiteral = FindControl("networklist") as Literal;

        networkListLiteral.Text = userProjectName == Global.PROJECT_QRA
            ?
                "<option value=\"network1\">Şebeke 1</option>" +
                "<option value=\"network2\">Şebeke 2</option>" +
                "<option value=\"allnetworks\" selected=\"selected\">Şebeke 1 + Şebeke 2</option>"
            :
                "<option value=\"dealersAndSatellitesJoined\">Şebeke 1: Y.S / Uydu Kümüle</option>" +
                "<option value=\"connectedPoints\">Şebeke 2: Bağlı Noktalar</option>" +
                (excludeS3 ? "" : "<option value=\"dealersAndSatellites\">Şebeke 3: Y.S / Uydu Detay</option>");

    }
}
